package com.df.hitime.common;

import lombok.extern.slf4j.Slf4j;

/**
 * @Description:
 * @Author: huangwl
 * @CreateDate: 2018/11/27 12:09
 */
@Slf4j
public class WeiXinUtils {

    public static String getTokenByCode(String code){
        String url=Constants.WX_AUTH_TOKEN_URL+"?appid="+Constants.WX_APPID+"&secret="+Constants.WX_SECRET+"&code="+code+"&grant_type=authorization_code";
        String result=HttpUtil.doGet(url);
        return result;
    }

    public static String getUserBaseByOpenId(String accessToken,String openId){
        String url=Constants.WX_AUTH_BASE_USER+"?access_token="+accessToken+"&openid="+openId+"&lang=zh_CN";
        String result=HttpUtil.doGet(url);
        return result;
    }

    public static void push(String url,String data,String token){
         url=Constants.WX_PUSH_URL+"?access_token="+token;
        try {
            String result=HttpUtil.doPost(url,data);
            log.info("微信推送返回信息:"+result);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
